﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ProduceBasicData.Api.Application.Command.ReceiveMaterials;
using ProduceBasicData.ErrorCode;

namespace ProduceBasicData.Api.Controllers
{
    /// <summary>
    /// 领料
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ReceiveMaterialsController : ControllerBase
    {
        private readonly IMediator mediator;

        public ReceiveMaterialsController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 领料
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> CreateReceiveMaterials(ReceiveMaterialsCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
